#include <iostream>

using namespace std;

struct Stack {
	int data[10000];
	int m_top;
	
	void set_top(int top) {
		m_top = top;
	}

	void push(int x) {
		m_top++;
		if(m_top < 10000) {
			data[m_top] = x;
		} else {
			m_top--;
			cout << "Stack overflow" << endl; 
		}
	}

	void pop() {
		if(m_top >= 0) {
			m_top--;
		}
	}

	int topval() {
		if(m_top >= 0) {
			return data[m_top];
		}
	}
};

int main()
{
	Stack s;
	s.set_top(-1);
	for(int i = 1; i <= 10; i++) {
		s.push(i);
	}

	for(int i = 1; i <= 10; i++) {
		cout << s.topval() << " ";
		s.pop();
	}

	return 0;
}